import axios from "axios";
//引入进度条
import nProgress from "nprogress";
import "nprogress/nprogress.css";
const mockRequests = axios.create({
  baseURL: "/mock",
  timeout: 50000,
});
//请求拦截器
mockRequests.interceptors.request.use((config) => {
  nProgress.start();
  return config;
});
//响应拦截器
mockRequests.interceptors.response.use(
  (res) => {
    //进度条结束
    nProgress.done();
    return res.data;
  },
  (error) => {
    return Promise.reject(new Error(error));
  }
);
export default mockRequests;
